﻿@model List<BTKERP.Model.RequisitionMaster> 
@{
    ViewBag.Title = "Requisition Management";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section AdditionalJS
{
    <script type="text/javascript">
        $(function () {
            $("#requeDate").datepicker();
        });
    </script>
}
<h2>Requisition Management</h2>
<form id="searchForm" name="searchForm" method="post">
<table class="editor W800">
    <thead>
        <tr>
            <td class="left" colspan="4">Requision Search</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td class="right W100">
                Requision Warehouse 
            </td>
            <td class="left W300">
             @Html.DropDownList("house", ViewData["WareHouseLisst"] as IEnumerable<SelectListItem>, new { @class = "W200 Margin10" })
            </td>
            <td class="right W100">
                Requision #
            </td>
            <td class="left W300">
                <input type="text" name="requeCode" id="requeCode" class="W200 Margin10"/>
            </td>
        </tr>
        <tr>
            <td class="right">
                Requision Date
            </td>
            <td class="left">
                <input type="text" class="W200 Margin10" id="requeDate" name="requeDate" readonly="readonly"/>
            </td>
            <td class="right">
                Requision By
            </td>
            <td class="left">
                @Html.DropDownList("UserList",ViewData["UserList"] as IEnumerable<SelectListItem>,"Please select" ,new { @class="W200 Margin10"})
            </td>
        </tr>
        <tr>
            <td class="right">
                Status
            </td>
            <td class="left" colspan="3">
                 <select class="W200 Margin10" id="status" name="status">
                    <option value="1">Pending</option>
                    <option value="2">Approved</option>
                    <option value="3">Rejected</option>
                    <option value="4">Canceled</option>
                    <option value="5">Delived</option>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="4" class="center">
                <input type="button" class="btn-blue" value="Search" onclick="$('#searchForm').submit();" />
                <input type="button" class="btn-red" value="Cancel" onclick="$('#searchForm')[0].reset();"/>
            </td>
        </tr>  
    </tbody>
</table>
</form>

<hr />
<table class="display stylized">
    <tr>
        <th>To Warehouse</th>
        <th>Req'd No.</th>
        <th>Req'd By</th>
        <th>Requisition Date</th>
        <th>Delivery Date</th>
        <th>Req'd Total</th>
        <th>Status</th>
        <th>View Detail</th>
        <th>Action</th>
    </tr>
    @if (Model != null && Model.Count > 0)
    {
        foreach (var master in Model)
        {
            <tr>
                <td>
                    @BTKERP.MVCWeb.AppCode.DataRefHelper.GetWarehouseById(master.ToWarehouseId)
                </td>
                <td>
                    @master.RequisitionCode
                </td>
                <td>
                    @master.RequisitionedBy
                </td>
                <td>
                    @master.RequisitionDate.ToString("MM/dd/yyyy")        
                </td>
                <td>
                    @master.DeliveryDate.Value.ToString("MM/dd/yyyy")
                </td>
                <td>
                    @master.RequisitionTotal.ToString("N0")
                </td>
                <td>
                    @BTKERP.MVCWeb.AppCode.DataRefHelper.GetRequisitionStatus(master.Status)
                </td>
                <td>
                    @Html.ActionLink("Detail", "Detail", new { id = master.Id.ToString() })

                    @if (master.Status == 1)
                    {
                            <td><a href="/Requisition/Approve/@master.Id.ToString()">Approve/Reject</a></td>
                    }
                    else 
                    {
                        <td></td> 
                    }
                </td>
            </tr>
        
        }
    }
    else
    {
        <tr>
            <td colspan="10">No Data Found</td>
        </tr>
    }
</table>